home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / misc / TownMaze.lha / TownMaze / src.lzh / fillmaze.c < prev    next >
C/C++ Source or Header  |  1991-08-04  |  1KB  |  64 lines

  1. /*
  2. ** fillmaze.c  Copyright 1991 Kent Paul Dolan,
  3. **             Mountain View, CA, USA 94039-0755
  4. **
  5. ** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
  6. ** May be freely used or modified in any non-commercial work.  Copyrighted
  7. ** only to prevent patenting by someone else.
  8. */
  9.  
  10. #include <stdio.h>
  11. #include "townmaze.h"
  12. #include "townproto.h"
  13.  
  14. #ifdef __STDC__
  15. void fillmaze()
  16. #else
  17. int fillmaze()
  18. #endif
  19. {
  20.   int i, j;
  21.  
  22. #if PROGRESS
  23.   fprintf(stderr,"Fill maze ");
  24. #endif
  25.  
  26. /*
  27. ** Fill maze with "wall" characters and "blank" characters,
  28. ** so that entire maze starts out as doorless rooms with walls
  29. ** between.
  30. */
  31.  
  32.   for (i = 0; i < mazeheight; i++)
  33.     for (j = 0; j < mazewidth; j++)
  34.       switch (((i%2)<<1) + (j%2))
  35.       {
  36.       case 0:
  37.         cmaze[i][j] = WALL;
  38.         break;
  39.       case 1:
  40.         cmaze[i][j] = WALL;
  41.         break;
  42.       case 2:
  43.         cmaze[i][j] = WALL;
  44.         break;
  45.       case 3:
  46.         cmaze[i][j] = BLANK;
  47.         break;
  48.       default:
  49.         fprintf(stderr,"failure in maze fill section\n");
  50.         freespace();
  51.         exit(1);
  52.       }
  53. /*
  54. ** The corner cells are too hard to use, so nuke them in the drawing.
  55. */
  56.  
  57.   cmaze[1][1]                 = WALL;
  58.   cmaze[1][mazewidth - 2]         = WALL;
  59.   cmaze[mazeheight - 2][1]        = WALL;
  60.   cmaze[mazeheight -2][mazewidth - 2] = WALL;
  61.  
  62.   return;
  63. }
  64.